import backend
#
#~ from etoffiutils2.list import head, tail
import time
#~ sys, os
#

False,True=0,1

class Server(backend.MessageTarget):
	def __init__(self):
		self.lines = []
		self.text = ''
		self._quitNow = False
		backend.initializeMsgTarget("AwxMessageServerDemo", self)
	def run(self):
		#~ m = backend.GetMessage()
		#~ if not m:
			#~ self._quitNow = True
		while not self._quitNow:
			time.sleep(1)
			#~ self.handle (m)
			#~ m = backend.GetMessage()
			#~ if not m:	
				#~ self._quitNow = True
	def handle(self, msg):
		if msg.main == 'expose qualify':
			r = backend.Message (self, self.target_, "respond qualify")
			r.add ("text", msg["text"].reverse()) 
			r.send ()
			
		#~ elif msg.main == 'expose lineadded':
			#~ self.addLine(msg)
	def init(self, args):
		pass
	
if __name__=='__main__':
	
	c = Server()
	c.init([])
	c.run()
